package br.com.dimension.imap2rest.holders;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.json.JSONException;
import org.json.JSONObject;

public class SimpleMessage {
Map <String,String> from = new HashMap<String,String>();
Map<String,String> to= new HashMap<String,String>();
Map<String,String> cc= new HashMap<String,String>();
Map<String,String> bcc= new HashMap<String,String>();
String subject;
Date date;
String body;
String preview;
int msgid;



Map<String,String> headers = new HashMap<String,String>();


public void addFrom(String mail,String name){
	from.put(mail, name);
}
public void addTo(String mail,String name){
	to.put(mail,name);
}
public void addCc(String mail,String name){
	cc.put(mail, name);
}
public void addBcc(String mail,String name){
	bcc.put(mail,name);
}

public void addHeader(String k,String v){
	headers.put(k, v);
}

public String toString(){
	return (from+":"+subject+":"+date.toString());
}
public int getMsgid() {
	return msgid;
}
public void setMsgid(int msgid) {
	this.msgid = msgid;
}
public Map<String,String> getFrom() {
	return from;
}
public void setFrom(Map<String,String> from) {
	this.from = from;
}
public Map<String,String> getTo() {
	return to;
}
public void setTo(Map<String,String> to) {
	this.to = to;
}
public Map<String,String> getCc() {
	return cc;
}
public void setCc(Map<String,String> cc) {
	this.cc = cc;
}
public Map<String,String> getBcc() {
	return bcc;
}
public void setBcc(Map<String,String> bcc) {
	this.bcc = bcc;
}
public String getSubject() {
	return subject;
}
public void setSubject(String subject) {
	this.subject = subject;
}
public Date getDate() {
	return date;
}
public void setDate(Date date) {
	this.date = date;
}
public String getBody() {
	return body;
}
public void setBody(String body) {
	this.body = body;
}
public Map<String, String> getHeaders() {
	return headers;
}
public void setHeaders(Map<String, String> headers) {
	this.headers = headers;
}

public String getPreview() {
	return preview;
}
public void setPreview(String preview) {
	this.preview = preview;
}

public JSONObject getJsonObject()throws JSONException{
	JSONObject obj = new JSONObject();
	
		obj.append("from", getFrom());
		obj.append("date", getDate().toString());
		obj.append("subject",getSubject());
		
	return obj;
}
}
